package org.hertsig.magiccardmarket.xml;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class DateAdapter extends XmlAdapter<String, Date> {
	private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); {
		format.setTimeZone(TimeZone.getTimeZone("UTC"));
	}
	
	@Override
	public Date unmarshal(String value) throws ParseException {
		return format.parse(value);
	}
	
	@Override
	public String marshal(Date value) {
		return format.format(value);
	}
}
